part of '../repository.dart';

class _LexicalItemProgressDtoFactory {
  const _LexicalItemProgressDtoFactory._internal();

  static const _instance = _LexicalItemProgressDtoFactory._internal();

  factory _LexicalItemProgressDtoFactory() {
    return _instance;
  }

  _LexicalItemProgressDto fromJson(Map<String, dynamic> json) {
    final type = json[_kLexicalItemProgressTypeKey] as String;

    switch (type) {
      case _kPreviouslyKnownLexicalItemProgressTypeValue:
        return _PreviouslyKnownLexicalItemProgressDto.fromJson(json);
      case _kLearningLexicalItemProgressTypeValue:
        return _LearningLexicalItemProgressDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }

  _LexicalItemProgressDto fromEntity(LexicalItemProgress lexicalItemProgress) {
    switch (lexicalItemProgress) {
      case PreviouslyKnownLexicalItemProgress():
        return _PreviouslyKnownLexicalItemProgressDto.fromEntity(lexicalItemProgress);
      case LearningLexicalItemProgress():
        return _LearningLexicalItemProgressDto.fromEntity(lexicalItemProgress);
    }
  }
}
